cmake_minimum_required(VERSION 3.15)

# #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx vcpkg配置，必须位于project之前
set(VCPKG_INSTALLED_DIR ${CMAKE_SOURCE_DIR}/vcpkg_installed)
if(DEFINED ENV{VCPKG_ROOT})
    set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") # 从环境变量中读取vcpkg根目录
else()
    set(VCPKG_ROOT "/home/tom/bin/vcpkg") # 手动设置vcpkg根目录
endif()
message(STATUS "[TPS] Set VCPKG_ROOT: ${VCPKG_ROOT}")
set(VCPKG_FEATURE_FLAGS "versions") # 用于支持自定义依赖版本
# 设置 vcpkg 工具链（根据你的路径修改）
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
# 避免每次都运行 vcpkg install;
# 如果需要重新运行 vcpkg install, 可以设置 cmake命令行参数 -DVCPKG_MANIFEST_INSTALL=ON
option(VCPKG_MANIFEST_INSTALL "re-run vcpkg install" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


project(DcmtkPcreDemo CXX)
# 查找依赖库
find_package(pcre2 REQUIRED)
find_package(DCMTK REQUIRED COMPONENTS data)

# 添加可执行文件
add_executable(main_app src/main.cpp)

# 链接库
target_link_libraries(main_app PRIVATE
    DCMTK::dcmdata
    pcre2::pcre2-8-shared
)

# 包含目录
target_include_directories(main_app PRIVATE
    ${DCMTK_INCLUDE_DIRS}
    ${PCRE2_INCLUDE_DIRS}
)